package com.example.block_chain.controller.admin;


import com.example.block_chain.common.ResponseResult;
import com.example.block_chain.common.SystemParameters;
import com.example.block_chain.domain.dto.AdminDto;
import com.example.block_chain.service.admin.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class AdminController {

    @Autowired
    private AdminService adminService;

    @PostMapping("/add/admin/")
    private ResponseResult addAdmin(@RequestBody AdminDto dto) {
        return adminService.addAdmin(dto);
    }

    @PostMapping("/delete/admin/")
    private ResponseResult deleteAdmin(@RequestBody AdminDto dto) {
        return adminService.deleteAdmin(dto);
    }

    @PostMapping("/update/admin/")
    private ResponseResult updateAdmin(@RequestBody AdminDto dto) {
        return adminService.updateAdmin(dto);
    }

    @PostMapping("/select/admin/")
    private ResponseResult selectAdmin(@RequestBody AdminDto dto) {
        return adminService.selectAdmin(dto);
    }

    @GetMapping("/select/admin/")
    private ResponseResult selectAdmin(@RequestParam String facultyCode, @RequestParam String schoolCode, @RequestParam String authority, @RequestParam Integer page, @RequestParam Integer pageSize) {
        pageSize = pageSize == null ? SystemParameters.PAGE_SIZE : pageSize;

        return adminService.selectAdmin(facultyCode, schoolCode, authority, page, pageSize);
    }
}
